<?xml version="1.0" encoding="UTF-8"?>
<!--
  Created by IntelliJ IDEA.
  User: azim
  Date: 5/20/13
  Time: 10:05 AM
-->

<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:composition template="templates/template.xhtml">

    <ui:define name="title">Category Add Page</ui:define>

    <ui:define name="navigation">

        <h:form>

            <p:tabMenu activeIndex="2">
                <p:menuitem value="Home" url="index.xhtml"/>
                <p:menuitem value="My Podcasts" action="#{podcastController.showAddForm}"/>
                <p:menuitem value="Category" url="show_podcast_categories.xhtml"/>
                <p:menuitem value="Account Settings" url="login_show_user_profile.xhtml"/>
            </p:tabMenu>

        </h:form>

    </ui:define>

    <ui:define name="left">

        <p:menuitem value="Add category"
                    ajax="false"
                    action="#{categoryController.showAddForm}"/>

    </ui:define>

    <ui:define name="cbody">

        <h2>Please fill up the following form for registration : </h2>
        <br/>
        <h:form id="create_category">

            <h:panelGrid columns="3" cellspacing="10" style="margin-bottom: 5px">

                <p:outputLabel styleClass="label" for="name" value="Name : "/>
                <p:inputText id="name"
                             value="#{categoryController.category.name}"
                             required="true"
                             requiredMessage="Error : Username is required"/>
                <p:message for="name" styleClass="error"/>

                <p:outputLabel styleClass="label" for="description" value="Description : "/>
                <p:inputTextarea id="description"
                                 value="#{categoryController.category.description}"
                                 rows="3" cols="50"/>
                <p:message for="description" styleClass="error"/>

                <p:outputLabel styleClass="label" for="parent" value="Parent : "/>
                <p:selectOneMenu id="parent"
                                 value="#{categoryController.category.parent}">

                    <f:selectItem itemLabel="No Parent" itemValue="0"/>

                    <f:selectItems value="#{categoryController.parents}"
                                   var="category"
                                   itemLabel="#{category.name}"
                                   itemValue="#{category.id}"/>

                </p:selectOneMenu>
                <p:message for="parent" styleClass="error"/>


            </h:panelGrid>

            <p:commandButton value="Add Category" ajax="false" action="#{categoryController.add()}"/>

        </h:form>

        <p:messages globalOnly="true"/>

    </ui:define>
</ui:composition>

</html>